#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
    int numberOfArrays(string s, int k) {
        vector<int> dp(s.size() + 1, 0);
        dp[0] = 1;
        for (int i = 1; i <= s.size(); i++) {
            for (int len = 1; len <= min(10, i); len++) {
                string sub = s.substr(i - len, len);
                if (sub[0] == '0') {
                    continue;
                }
                int64_t val = stoll(sub);
                if (val > k) {
                    break;
                }
                dp[i] = (dp[i] + dp[i - len]) % (int64_t) (1e9 + 7);
            }
        }
        return dp[s.size()];
    }
};

int main() {
    Solution solution;
    int a = solution.numberOfArrays("1317", 2000);
    return 0;
}